package com.fer.tankr.huds;

import org.andengine.engine.camera.hud.HUD;
import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.text.Text;
import org.andengine.input.touch.TouchEvent;
import org.andengine.opengl.font.IFont;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.fer.tankr.controllers.GameController;

public class GameHud extends HUD implements IHud{

	Text livesText;
	Text coinsText;
	int totalCoins;
	Text bulletsText;
	
	public GameHud(VertexBufferObjectManager vbom, IFont font, float width, float height, ITextureRegion pauseButton, final GameController activity,
			ITextureRegion coinTexture, ITextureRegion ammo) {
		
		livesText = new Text(0, 5, font, "Lives: XX", "Lives: XX".length(), vbom);
		coinsText = new Text(livesText.getX()+livesText.getWidth()+5, 5, font, "Coins: XXXXX","Coins: XXXXX".length(), vbom);
		bulletsText = new Text(coinsText.getX()+coinsText.getWidth()+5, 5, font, "Ammo","Ammo: XXX".length(), vbom);
		attachChild(livesText);
		attachChild(coinsText);
		attachChild(bulletsText);
		
		Sprite sprite = new Sprite(width-pauseButton.getWidth(), 0, pauseButton, vbom)
		{
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) 
			{
				activity.pause();
				return true;
			};
		};
		
		attachChild(sprite);
		registerTouchArea(sprite);
	}
	
	@Override
	public void setCoins(int coins) {
		coinsText.setText("Coins: "+coins+"/"+totalCoins);
	}

	@Override
	public void setLives(int lives) {
		livesText.setText("Lives: "+lives);
	}

	@Override
	public void setScoreRemaining(long time) {
		//timeText.setText("Score: "+time);
	}

	@Override
	public void setBullets(int bullets) {
		bulletsText.setText("Ammo: "+bullets);
	}

	@Override
	public void setTotal(int total) {
		totalCoins=total;
		
	}

	
}
